package com.lineng.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lineng.dao.UserMapper;
import com.lineng.pojo.User;
import com.lineng.service.LoginService;

@Service
public class LoginServiceImpl implements LoginService {

	@Autowired
	UserMapper userMapper;

	public User loginUser(String username, String password) {
		User user = new User();
		try {
			if (username != null && password != null) {
				user = userMapper.getUserByuserNameAndPassword(username, password);
				if (user != null && user.getUsername().equals(username) && user.getPassword().equals(password)) {
					return user;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;

	}
}
